<?php
/**
 * Created by PhpStorm.
 * AdminUser: Administrator
 * Date: 2020/11/19
 * Time: 14:59
 */
declare(strict_types = 1);
namespace app\admin\middleware;

class Auth
{
    public function handle($request, \Closure $next)
    {
        if (empty(session('admin_id')) && !preg_match("/login/", $request->pathinfo())) {
            return redirect((string) url('/admin/login/index'));
        }

        $response = $next($request);
//        if (empty(session(config('controller.session_admin'))) && $request->controller() != 'Login') {
//            return redirect((string) url('login/index'));
//        }



        return  $response;
    }

    public function end(\think\Response $response)
    {

    }
}